﻿@model ContactManagement.Models.UserListModel
@{
    ViewBag.Title = GlobalResources.AdminViews.UserListRESX;
}

<div class="span12">
    <h2 class="span5">@GlobalResources.AdminViews.UserListRESX</h2>
    <div id="qsearch" class="pull-right" style="display: none"></div>
</div>

<div class="span12">
    <hr />
    @Html.ShowCustomMessage()
</div>

<div class="span12">
    @Html.Paging().Create(Model.Users)
</div>

<div class="span12">
    <table class="table table-striped table-condensed @WebConstants.FilterTableRowsCssClass">
        <thead>
            <tr>
                <th>@GlobalResources.AccountViews.OptionsRESX
                </th>
                <th>
                    @Html.TableHeaderLinks("UserTitle", GlobalResources.AccountViews.TitleRESX).CreateSortLink()
                </th>
                <th>
                    @Html.TableHeaderLinks("Firstname", GlobalResources.AccountViews.FirstnameRESX).CreateSortLink()
                </th>
                <th>
                    @Html.TableHeaderLinks("Lastname", GlobalResources.AccountViews.LastnameRESX).CreateSortLink()
                </th>
                <th>
                    @Html.TableHeaderLinks("LoginEmail", GlobalResources.AccountViews.LoginnameRESX).CreateSortLink()
                </th>
                <th>
                    @Html.TableHeaderLinks("UserCategory", GlobalResources.AccountViews.UserCategoryRESX).CreateSortLink()
                </th>
                <th>@GlobalResources.AccountViews.LoginActiveRESX
                </th>
                <th>
                    @Html.TableHeaderLinks("Creator", GlobalResources.AdminViews.CreatorRESX).CreateSortLink()
                </th>
            </tr>
        </thead>
        <tbody>
            @{ System.Diagnostics.Stopwatch time = new System.Diagnostics.Stopwatch(); }
            @{ System.Diagnostics.Stopwatch time2 = new System.Diagnostics.Stopwatch();
               time2.Start(); }
            @foreach (EFDataModel.EFUser eUser in Model.Users.CurrentPageEntriesOrderByUrl(WebConstants.PageSizePaging))
            {
                <tr data-id="@eUser.ID">
                    <td>
                        @{time.Start(); }
                        @if (WebRights.Right().Check(EUserRights.UserDetails))
                        { @Html.ActionLink(" ", EActionUser.UserDetails.ToString(), new { id = eUser.ID }, new { @class = "btn btn-mini", data_icon = "icon-cog", title = GlobalResources.Navigation.DetailsRESX }) }
                        @if (WebRights.Right().Check(EUserRights.UserEdit))
                        {  @Html.ActionLink(" ", EActionUser.UserEdit.ToString(), new { id = eUser.ID }, new { @class = "btn btn-mini", data_icon = "icon-pencil", title = GlobalResources.Navigation.EditRESX }) }
                        @if (WebRights.Right().Check(EUserRights.SetUserRights))
                        { @Html.ActionLink(" ", EActionUser.UserEditUserRights.ToString(), new { id = eUser.ID }, new { @class = "btn btn-mini", data_icon = "icon-book", title = GlobalResources.Navigation.EditUserRightsRESX }) }
                        @if (WebRights.Right().Check(EUserRights.SetUserGroups))
                        { @Html.ActionLink(" ", EActionUser.UserEditUserGroups.ToString(), new { id = eUser.ID }, new { @class = "btn btn-mini", data_icon = "icon-user", title = GlobalResources.Navigation.EditUserGroupsRESX }) }
                    </td>
                    <td>@Html.Categories().DisplayForCategory(eUser.UserTitleID.ToString())
                    </td>
                    <td>@Html.DisplayFor(modelItem => eUser.Firstname)
                    </td>
                    <td>@Html.DisplayFor(modelItem => eUser.Lastname)
                    </td>
                    <td>@Html.DisplayFor(modelItem => eUser.LoginEmail)
                    </td>
                    <td>@Html.DisplayFor(modelItem => eUser.UserCategory.Name)
                    </td>
                    <td>
                        @{
                        if (eUser.IsActiveUser)
                        {
                            @GlobalResources.GlobalStrings.YesRESX;
                        }
                        else
                        {
                            @GlobalResources.GlobalStrings.NoRESX;
                        }
                        }
                    </td>
                    <td>
                        @{ //Der ersteller kann nur angezeigt werden, wenn dieser auch gesetzt wurde.
                        if (eUser.CreatorID.HasValue)
                        {
                            @eUser.Creator.GetFullName();
                        }
                        time.Stop();
                //EFDebugging.Debugging.WriteLog("DS: " + time.ElapsedMilliseconds + "\r\n");
                        }
                    </td>
                </tr>
                        
            }
            @{
                time2.Stop();
                EFDebugging.Debugging.WriteLog("Gesamt: " + time2.ElapsedMilliseconds + "\r\n");
            }
        </tbody>
    </table>
</div>

<div class="span12">
    <div class="well">
        @Html.ActionLink(GlobalResources.Navigation.BackToStartpageRESX, EActionHome.Index.ToString(), EControllers.Home.ToString(), null, new { @class = "btn btn-small", data_icon = "icon-arrow-left" })
    </div>
</div>

